Test Series - Data Structure

Test Number 6/115

Q: The result of evaluating the postfix expression 5, 4, 6, +, *, 4, 9, 3, /, +, * is?
A. 600
B. 350
C. 650
D. 588
Solution: The postfix expression is evaluated using stack. We will get the infix expression as
(5*(4+6))*(4+9/3). On solving the Infix Expression, we get
(5*(10))*(4+3)
= 50*7
= 350.
Q: Convert the following infix expressions into its equivalent postfix expressions.
(A + B ⋀D)/(E – F)+G
A. (A B D ⋀ + E F – / G +)
B. (A B D +⋀ E F – / G +)
C. (A B D ⋀ + E F/- G +)
D. (A B D E F + ⋀ / – G +)
Solution: The given infix expression is (A + B ⋀D)/(E – F)+G.
(A B D ^ + ) / (E – F) +G
(A B D ^ + E F – ) + G. ‘/’ is present in stack.
A B D ^ + E F – / G +. Thus Postfix Expression is A B D ^ + E F – / G +.
Q: Convert the following Infix expression to Postfix form using a stack.
x + y * z + (p * q + r) * s, Follow usual precedence rule and assume that the expression is legal.
A. xyz*+pq*r+s*+
B. xyz*+pq*r+s+*
C. xyz+*pq*r+s*+
D. xyzp+**qr+s*+
Solution: The Infix Expression is x + y * z + (p * q + r) * s.
(x y z ) + (p * q + r) * s. ‘+’, ‘*’ are present in stack.
(x y z * + p q * r) * s. ‘+’ is present in stack.
x y z * + p q * r + s * +. Thus Postfix Expression is x y z * + p q * r + s * +.
Q: Which of the following statement(s) about stack data structure is/are NOT correct?
A. Linked List are used for implementing Stacks
B. Top of the Stack always contain the new node
C. Stack is the FIFO data structure
D. Null link is present in the last node at the bottom of the stack
Solution: Stack follows LIFO.
Q: Consider the following operation performed on a stack of size 5.

Push(1);
Pop();
Push(2);
Push(3);
Pop();
Push(4);
Pop();
Pop();
Push(5);
After the completion of all operation, the number of elements present in stack is?
A. 1
B. 2
C. 3
D. 4
Solution: Number of elements present in stack is equal to the difference between number of push operations and number of pop operations. Number of elements is 5-4=1.
Q: Which of the following is not an inherent application of stack?
A. Reversing a string
B. Evaluation of postfix expression
C. Implementation of recursion
D. Job scheduling
Solution: Job Scheduling is not performed using stacks.
Q: The type of expression in which operator succeeds its operands is?
A. Infix Expression
B. Prefix Expression
C. Postfix Expression
D. Both Prefix and Postfix Expressions
Solution: The expression in which operator succeeds its operands is called postfix expression. The expression in which operator precedes the operands is called prefix expression. If an operator is present between two operands, then it is called infix expressions.
Q: Assume that the operators +,-, X are left associative and ^ is right associative. The order of precedence (from highest to lowest) is ^, X, +, -. The postfix expression for the infix expression a + b X c – d ^ e ^ f is?
A. abc X+ def ^^ –
B. abc X+ de^f^ –
C. ab+c Xd – e ^f^
D. -+aXbc^ ^def
Solution: Given Infix Expression is a + b X c – d ^ e ^ f.
(a b c X +) (d ^ e ^ f). ‘–‘ is present in stack.
(a b c X + d e ^ f ^ -). Thus the final expression is (a b c X + d e ^ f ^ -).
Q: If the elements “A”, “B”, “C” and “D” are placed in a stack and are deleted one at a time, what is the order of removal?
A. ABCD
B. DCBA
C. DCAB
D. ABDC
Solution: Stack follows LIFO(Last In First Out). So the removal order of elements are DCBA.
Q: 
A. 
B. 
C. 
D. 
Solution: 

You Have Score    /10